<template>
  <div>
    <el-table :data="tableData" style="width: 100%" >
      <el-table-column label="资产项目" prop="projectName" class-name="bg-color-82DEB5" header-align="left" align="left"> </el-table-column>

      <el-table-column label="财年" class-name="bg-color-82DEB5" header-align="left" align="left">
        <template slot-scope="scope"> {{ scope.row.fiscalYear }} </template>
      </el-table-column>

      <el-table-column label="状态" class-name="bg-color-82DEB5" header-align="left" align="left">
        <template slot-scope="scope"> {{ scope.row.planDescStatus }} </template>
      </el-table-column>

      <el-table-column label="操作" width="100" header-align="center" align="center">
        <template slot-scope="scope">
          <el-button @click="handleView(scope.row)" type="text" size="small">点击查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { getMenuList } from '@/api';
export default {
  props: {
    tableData: {
      type: Array,
      default: () => {
        return {};
      },
    },
  },
  methods: {
    async handleView(item) {
      let res = await getMenuList({
        parentId: this.$route.query.menuId,
        likeDescription: item.planDescStatus == '编制中' ? '0' : '1',
      });
      let year = item.fiscalYear.substring(0, 4);
      let menuUrl = res.rows[0].menuUrl;
      let separator = menuUrl.indexOf('?') > -1 ? '&' : '?';
      let queryData = {
        isRefresh: true,
        parentMenuId: this.$route.query.menuId,
        menuId: res.rows[0].primaryKey,
        type: item.planDescStatus == '编制中' ? '1' : '2',
        likeDescription: item.planDescStatus == '编制中' ? '0' : '1',
        planKey: item.primaryKey,
        year,
      };

      let paramData = [];
      for (let key in queryData) {
        paramData.push(key + '=' + queryData[key]);
      }

      let href = menuUrl + separator + paramData.join('&');
      window.open(href);
    }
  }
};
</script>